from heap.slot import Slots
from jthread.frame import JFrame
from jthread.stack import JStack


class JThread:

    def __init__(self):
        self.pc = 0
        self.stack: JStack = None

    @staticmethod
    def newThread():
        jt = JThread()
        maxStack = 1024
        jt.stack = JStack.newJStack(maxStack=maxStack)

        return jt

    def getPC(self):
        return self.pc

    def setPC(self, pc):
        self.pc = pc

    def getStack(self):
        return self.stack

    def newFrame(self, method):
        return JFrame.newJFrame(self, method)

    def pushFrame(self, frame):
        self.stack.push(frame)

    def topFrame(self):
        return self.stack.top()

    def setPc(self, pc):
        self.pc = pc

    def getPc(self):
        return self.pc

    def isEmpty(self) -> bool:
        return self.stack.isEmpty()

    def popFrame(self):
        self.stack.pop()
